﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace secretserver.Data.Migrations
{
    public partial class InitialCreate : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Players",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    IpAddress = table.Column<string>(type: "TEXT", nullable: true),
                    LastLoginTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    QQExpireTime = table.Column<int>(type: "INTEGER", nullable: false),
                    QQToken = table.Column<string>(type: "TEXT", nullable: true),
                    QQUserId = table.Column<string>(type: "TEXT", nullable: true),
                    SupportAvatar = table.Column<string>(type: "TEXT", nullable: true),
                    SupportNickname = table.Column<string>(type: "TEXT", nullable: true),
                    WechatExpireTime = table.Column<int>(type: "INTEGER", nullable: false),
                    WechatToken = table.Column<string>(type: "TEXT", nullable: true),
                    WechatUserId = table.Column<string>(type: "TEXT", nullable: true),
                    WeiboExpireTime = table.Column<int>(type: "INTEGER", nullable: false),
                    WeiboToken = table.Column<string>(type: "TEXT", nullable: true),
                    WeiboUserId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Players", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Worlds",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    Background = table.Column<byte[]>(type: "BLOB", nullable: true),
                    StartDate = table.Column<DateTime>(type: "TEXT", nullable: false),
                    Title = table.Column<string>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Worlds", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Characters",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    Age = table.Column<int>(type: "INTEGER", nullable: false),
                    Avatar = table.Column<string>(type: "TEXT", nullable: false),
                    Background = table.Column<string>(type: "TEXT", nullable: true),
                    Blood = table.Column<int>(type: "INTEGER", nullable: false),
                    Description = table.Column<string>(type: "TEXT", nullable: false),
                    Ellation = table.Column<int>(type: "INTEGER", nullable: false),
                    Height = table.Column<int>(type: "INTEGER", nullable: false),
                    IsManual = table.Column<bool>(type: "INTEGER", nullable: false),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    Picture = table.Column<string>(type: "TEXT", nullable: true),
                    Profession = table.Column<string>(type: "TEXT", nullable: true),
                    Sex = table.Column<int>(type: "INTEGER", nullable: false),
                    SkinColor = table.Column<string>(type: "TEXT", nullable: true),
                    SourceArea = table.Column<string>(type: "TEXT", nullable: true),
                    WorldId = table.Column<Guid>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Characters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Characters_Worlds_WorldId",
                        column: x => x.WorldId,
                        principalTable: "Worlds",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "WorldScenes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    Arctived = table.Column<bool>(type: "INTEGER", nullable: false),
                    Background = table.Column<string>(type: "TEXT", nullable: true),
                    NowDate = table.Column<DateTime>(type: "TEXT", nullable: false),
                    PlayDuration = table.Column<int>(type: "INTEGER", nullable: false),
                    PlayerId = table.Column<Guid>(type: "BLOB", nullable: false),
                    Title = table.Column<string>(type: "TEXT", nullable: false),
                    WorldId = table.Column<Guid>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorldScenes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WorldScenes_Players_PlayerId",
                        column: x => x.PlayerId,
                        principalTable: "Players",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_WorldScenes_Worlds_WorldId",
                        column: x => x.WorldId,
                        principalTable: "Worlds",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Topices",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    BreakCondition = table.Column<int>(type: "INTEGER", nullable: false),
                    CharacterId = table.Column<Guid>(type: "BLOB", nullable: false),
                    FirstQuestion = table.Column<string>(type: "TEXT", nullable: false),
                    FuckerCondition = table.Column<int>(type: "INTEGER", nullable: false),
                    MarryCondition = table.Column<int>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Topices", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Topices_Characters_CharacterId",
                        column: x => x.CharacterId,
                        principalTable: "Characters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "CharacterScenes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    AVUser = table.Column<string>(type: "TEXT", nullable: false),
                    Age = table.Column<int>(type: "INTEGER", nullable: false),
                    Avatar = table.Column<string>(type: "TEXT", nullable: false),
                    Background = table.Column<string>(type: "TEXT", nullable: true),
                    Blood = table.Column<int>(type: "INTEGER", nullable: false),
                    CharacterId = table.Column<Guid>(type: "BLOB", nullable: false),
                    Description = table.Column<string>(type: "TEXT", nullable: false),
                    Ellation = table.Column<int>(type: "INTEGER", nullable: false),
                    Height = table.Column<int>(type: "INTEGER", nullable: false),
                    IsManual = table.Column<bool>(type: "INTEGER", nullable: false),
                    Name = table.Column<string>(type: "TEXT", nullable: false),
                    Picture = table.Column<string>(type: "TEXT", nullable: true),
                    Profession = table.Column<string>(type: "TEXT", nullable: true),
                    Sex = table.Column<int>(type: "INTEGER", nullable: false),
                    SkinColor = table.Column<string>(type: "TEXT", nullable: true),
                    SourceArea = table.Column<string>(type: "TEXT", nullable: true),
                    WorldSceneId = table.Column<Guid>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CharacterScenes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CharacterScenes_Characters_CharacterId",
                        column: x => x.CharacterId,
                        principalTable: "Characters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_CharacterScenes_WorldScenes_WorldSceneId",
                        column: x => x.WorldSceneId,
                        principalTable: "WorldScenes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Rounds",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    BreakChange = table.Column<int>(type: "INTEGER", nullable: false),
                    FuckerChange = table.Column<int>(type: "INTEGER", nullable: false),
                    Index = table.Column<int>(type: "INTEGER", nullable: false),
                    MarryChange = table.Column<int>(type: "INTEGER", nullable: false),
                    NextQuestion = table.Column<string>(type: "TEXT", nullable: false),
                    Question = table.Column<string>(type: "TEXT", nullable: false),
                    TopicId = table.Column<Guid>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Rounds", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Rounds_Topices_TopicId",
                        column: x => x.TopicId,
                        principalTable: "Topices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Couples",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "BLOB", nullable: false),
                    AiCharacterSceneId = table.Column<Guid>(type: "BLOB", nullable: false),
                    Break = table.Column<int>(type: "INTEGER", nullable: false),
                    ConversationId = table.Column<string>(type: "TEXT", nullable: false),
                    CurrentTopicId = table.Column<Guid>(type: "BLOB", nullable: false),
                    Fucker = table.Column<int>(type: "INTEGER", nullable: false),
                    ManualCharacterSceneId = table.Column<Guid>(type: "BLOB", nullable: false),
                    Marry = table.Column<int>(type: "INTEGER", nullable: false),
                    Status = table.Column<int>(type: "INTEGER", nullable: false),
                    WorldSceneId = table.Column<Guid>(type: "BLOB", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Couples", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Couples_CharacterScenes_AiCharacterSceneId",
                        column: x => x.AiCharacterSceneId,
                        principalTable: "CharacterScenes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Couples_Topices_CurrentTopicId",
                        column: x => x.CurrentTopicId,
                        principalTable: "Topices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Couples_CharacterScenes_ManualCharacterSceneId",
                        column: x => x.ManualCharacterSceneId,
                        principalTable: "CharacterScenes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Couples_WorldScenes_WorldSceneId",
                        column: x => x.WorldSceneId,
                        principalTable: "WorldScenes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Characters_WorldId",
                table: "Characters",
                column: "WorldId");

            migrationBuilder.CreateIndex(
                name: "IX_CharacterScenes_CharacterId",
                table: "CharacterScenes",
                column: "CharacterId");

            migrationBuilder.CreateIndex(
                name: "IX_CharacterScenes_WorldSceneId",
                table: "CharacterScenes",
                column: "WorldSceneId");

            migrationBuilder.CreateIndex(
                name: "IX_Couples_AiCharacterSceneId",
                table: "Couples",
                column: "AiCharacterSceneId");

            migrationBuilder.CreateIndex(
                name: "IX_Couples_CurrentTopicId",
                table: "Couples",
                column: "CurrentTopicId");

            migrationBuilder.CreateIndex(
                name: "IX_Couples_ManualCharacterSceneId",
                table: "Couples",
                column: "ManualCharacterSceneId");

            migrationBuilder.CreateIndex(
                name: "IX_Couples_WorldSceneId",
                table: "Couples",
                column: "WorldSceneId");

            migrationBuilder.CreateIndex(
                name: "IX_Rounds_TopicId",
                table: "Rounds",
                column: "TopicId");

            migrationBuilder.CreateIndex(
                name: "IX_Topices_CharacterId",
                table: "Topices",
                column: "CharacterId");

            migrationBuilder.CreateIndex(
                name: "IX_WorldScenes_PlayerId",
                table: "WorldScenes",
                column: "PlayerId");

            migrationBuilder.CreateIndex(
                name: "IX_WorldScenes_WorldId",
                table: "WorldScenes",
                column: "WorldId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Couples");

            migrationBuilder.DropTable(
                name: "Rounds");

            migrationBuilder.DropTable(
                name: "CharacterScenes");

            migrationBuilder.DropTable(
                name: "Topices");

            migrationBuilder.DropTable(
                name: "WorldScenes");

            migrationBuilder.DropTable(
                name: "Characters");

            migrationBuilder.DropTable(
                name: "Players");

            migrationBuilder.DropTable(
                name: "Worlds");
        }
    }
}
